
getch()
{
  char *KEYPRESS = (char*)0xC000;           /* return the last key press  */
  char *KEYCLEAR = (char*)0xC010;           /* clear the last key press   */
  char c;
            /* clear stragglers from the keyboard buffer */
            while((c=KEYPRESS[0]) > 127)KEYCLEAR[0]=0;

            /* read the keyboard buffer    */
            /* and return the character    */
            do{
               c = KEYPRESS[0];
               }while(c < 128);

               c-=128;
               KEYCLEAR[0]=0;
               return (int )c;
}

